#Boa:Frame:Frame1

import wx
import wx.lib.hyperlink
from wx.lib.anchors import LayoutAnchors
import wx.richtext

def create(parent):
    return Frame1(parent)

[wxID_FRAME1, wxID_FRAME1BUTTON1, wxID_FRAME1HYPERLINKCTRL1, 
 wxID_FRAME1RICHTEXTCTRL1, wxID_FRAME1RICHTEXTCTRL2, wxID_FRAME1STATICTEXT1, 
 wxID_FRAME1TEXTCTRL1, 
] = [wx.NewId() for _init_ctrls in range(7)]

class Frame1(wx.Frame):
    def _init_ctrls(self, prnt):
        # generated method, don't edit
        wx.Frame.__init__(self, id=wxID_FRAME1, name='', parent=prnt,
              pos=wx.Point(238, 207), size=wx.Size(615, 485),
              style=wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.RESIZE_BOX | wx.MAXIMIZE_BOX),
              title='Code Helper')
        self.SetClientSize(wx.Size(607, 458))
        self.SetBackgroundStyle(wx.BG_STYLE_SYSTEM)
        self.SetToolTipString('Immensetech Code Helper')
        self.SetThemeEnabled(True)
        self.SetIcon(wx.Icon(u'app.ico',wx.BITMAP_TYPE_ICO))
        self.SetHelpText('')

        self.richTextCtrl1 = wx.richtext.RichTextCtrl(id=wxID_FRAME1RICHTEXTCTRL1,
              parent=self, pos=wx.Point(8, 8), size=wx.Size(224, 440),
              style=wx.richtext.RE_MULTILINE, value='')
        self.richTextCtrl1.SetLabel('text')

        self.button1 = wx.Button(id=wxID_FRAME1BUTTON1, label='Generate',
              name='button1', parent=self, pos=wx.Point(536, 88),
              size=wx.Size(64, 24), style=0)
        self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
              id=wxID_FRAME1BUTTON1)

        self.richTextCtrl2 = wx.richtext.RichTextCtrl(id=wxID_FRAME1RICHTEXTCTRL2,
              parent=self, pos=wx.Point(240, 120), size=wx.Size(360, 328),
              style=wx.richtext.RE_MULTILINE, value='')
        self.richTextCtrl2.SetLabel('text')

        self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME1TEXTCTRL1, name='textCtrl1',
              parent=self, pos=wx.Point(240, 88), size=wx.Size(288, 24),
              style=0, value='cmd.SetParam("@$I", entity.$1);')

        self.staticText1 = wx.StaticText(id=wxID_FRAME1STATICTEXT1,
              label='Iterate text: (use $1 and/or $I as replacement key) \n$1 - will be replaced by each line on the left \n$I - will be replaced by the Pascal representation of the line on the left - \n       capitalize the first character and remove _ then capitalize the \n       following character.',
              name='staticText1', parent=self, pos=wx.Point(248, 8),
              size=wx.Size(348, 65), style=0)
        self.staticText1.SetConstraints(LayoutAnchors(self.staticText1, True,
              True, False, False))

        self.hyperLinkCtrl1 = wx.lib.hyperlink.HyperLinkCtrl(id=wxID_FRAME1HYPERLINKCTRL1,
              label='Free utilities from Immensetech', name='hyperLinkCtrl1',
              parent=self, pos=wx.Point(448, 72), size=wx.Size(150, 13),
              style=0)

    def __init__(self, parent):
        self._init_ctrls(parent)
        self.hyperLinkCtrl1.SetURL('http://www.immensetech.com')
        self.hyperLinkCtrl1.SetBackgroundColour(self.GetBackgroundColour())

    def OnButton1Button(self, event):
        strLeft = self.richTextCtrl1.GetValue() #lines of vars
        strTemp = self.textCtrl1.GetValue() #template
        listLeft = strLeft.split('\n') #split left into array
        strTempList = ''
        for str in listLeft: #each line on left
            #capitalize all letters after '_' and the first letter
            listPascal = str.split('_')
            strPascal = ''
            for s in listPascal:
                strPascal += s.capitalize()
            strThisTemp = strTemp
            strTempList += strThisTemp.replace("$1", str).replace("$I", strPascal)
            strTempList += "\n"
        self.richTextCtrl2.SetValue(strTempList)
